home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Magnum One
/
Magnum One (Mid-American Digital) (Disc Manufacturing).iso
/
d20
/
yuck_200.arc
/
YUCKNL.C
< prev
Wrap
C/C++ Source or Header
|
1990-10-29
|
6KB
|
184 lines
#include "yuck.h" /* define miscellany */
/* ========================================================================= */
Byte * getComma( Byte * p, Byte * Temp )
{
Byte * q;
int n;
q = strchr( p, ',' );
if ( q == NULL ) {
printf( "getComma failed: '%s'\n", p );
exit( 1 );
}
n = min( q - p, STRSIZ );
if ( q > p ) memcpy( Temp, p, n );
Temp[n] = EOS;
assert( Temp, STRSIZ );
return q + 1;
}
/* ========================================================================= */
void parseRec( Byte * Line, tNod * Buf, int Action )
{
Byte * p, * q; /* parser pointers */
long temp; /* for node# parse */
static Byte Temp[STRSIZ + 1]; /* temp hold area */
static tAd ad; /* last node processed */
/* ------------------------------------------------------------------------- */
switch ( Action ) {
case 0: break; /* normal parse */
case 1: ad.z = ad.n = ad.f = ad.p = 0; return; /* reset */
case 2: break; /* no default fill */
default: return; /* that's what _I_ call error checking */
}
/* ------------------------------------------------------------------------- */
q = getComma( Line, Temp );
Buf->Type = Node; /* preload */
if ( stricmp( Temp, "Zone" ) == 0 )
Buf->Type = Zone;
else if ( stricmp( Temp, "Region" ) == 0 )
Buf->Type = Region;
else if ( stricmp( Temp, "Host" ) == 0 )
Buf->Type = Host;
else if ( stricmp( Temp, "Hub" ) == 0 )
Buf->Type = Hub;
else if ( stricmp( Temp, "Point" ) == 0 )
Buf->Type = Point;
else if ( stricmp( Temp, "Pvt" ) == 0 )
Buf->Type = Pvt;
else if ( stricmp( Temp, "Down" ) == 0 )
Buf->Type = Down;
else if ( stricmp( Temp, "Boss" ) == 0 ) {
parseRec( NULL, NULL, 1 ); /* reset ourselves */
parseAd( q, &ad );
Buf->a = ad;
Buf->Type = Node;
Buf->No = Buf->a.f;
Buf->Bbs[0] = Buf->City[0] = Buf->Sysop[0] =
Buf->Tel[0] = Buf->Flags[0] = EOS;
Buf->Baud = 9600;
return;
}
/* ------------------------------------------------------------------------- */
p = getComma( q, Temp );
if ( strlen( Temp ) == 0 ) {
printf( "parseRec: no node# '%s'\n", Line );
exit( 1 );
}
temp = strtol( Temp, &q, 10 ); /* get node # */
if ( temp < 0L || temp > 65535L ) {
printf( "parseRec: bad node# %ld\n", Temp );
exit( 1 );
}
Buf->No = (Word) temp;
if ( ( inFd199b == Yes || inPointnet == Yes ) && Cfg.keepPvt == Yes )
if ( Buf->Type == Pvt )
Buf->Type = Node; /* keep private points */
if ( Action == 2 ) /* set node# */
Buf->a.f = Buf->No;
else {
Buf->a = ad; /* copy defaults */
switch ( Buf->Type ) {
case Zone: Buf->a.z = Buf->a.n = Buf->No;
Buf->a.f = Buf->a.p = 0;
break;
case Region:
case Host: Buf->a.n = Buf->No;
Buf->a.f = Buf->a.p = 0;
break;
case Point: Buf->a.p = Buf->No;
break;
default: Buf->a.f = Buf->No;
Buf->a.p = 0;
break;
}
if ( inFd199b == Yes ) {
Word temp;
temp = Buf->a.f;
Buf->a = ad;
Buf->a.p = temp;
Buf->Type = Point;
}
ad = Buf->a; /* set default for next time */
}
/* ------------------------------------------------------------------------- */
/* CLIST supports a special entry format on amigas. if it encounters a line */
/* of the sort "{type},{node#},->" (note the arrow), it reads the node's */
/* data from the main nodelist. that doesn't work for points. anyway, since */
/* Yuck! takes data for non-point systems _always_ from the nodelist, it */
/* can't hurt to support this format. */
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
if ( inPointnet == Yes && Buf->Type != Point &&
*p == '-' && p[1] == '>' ) { /* ",3,->" for amiga */
*Buf->Bbs = *Buf->City = *Buf->Sysop =
*Buf->Tel = *Buf->Flags = EOS;
Buf->Baud = POINTBAUD;
return;
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
q = getComma( p, Buf->Bbs ); Buf->Bbs[STRSIZ] = EOS;
p = getComma( q, Buf->City ); Buf->City[STRSIZ] = EOS;
q = getComma( p, Buf->Sysop ); Buf->Sysop[STRSIZ] = EOS;
p = getComma( q, Buf->Tel ); Buf->Tel[STRSIZ] = EOS;
Buf->Baud = (Word) strtol( p, &q, 10 );
if ( *q != ',' ) {
printf( "parseRec: no flags '%s'\n", q );
exit( 1 );
}
q ++;
strncpy( Buf->Flags, q, STRSIZ ); Buf->Flags[STRSIZ] = EOS;
assert( Buf->Bbs, STRSIZ );
assert( Buf->City, STRSIZ );
assert( Buf->Sysop, STRSIZ );
assert( Buf->Tel, STRSIZ );
assert( Buf->Flags, STRSIZ );
}
/* ========================================================================= */
tNod * newNod( void )
{
tNod * p;
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
p = malloc( sizeof( tNod ) );
if ( p == NULL ) {
puts( "\nsorry, friend, but i just ran out of memory. currently, i have some" );
printf( "%u entries stashed away, and that _does_ seem a bit exaggerating.\n", maxpt );
exit( 99 );
}
p->nx = NULL;
return p;
}
/* ========================================================================= */
tNod * addNod( int addCopy, tNod * Node )
{
tNod * p;
if ( addCopy ) { /* make a copy for list entry? */
p = newNod();
*p = *Node;
}
else p = Node;
p->nx = pts;
pts = p;
return p;
}
/* ========================================================================= */
void delNod( tNod * p )
{
tNod * q;
tNod * r;
if ( p = pts ) /* list head? */
pts = p->nx;
else {
for ( r = pts, q = pts->nx; q != NULL; q = q->nx ) {
if ( q == p ) {
r->nx = q->nx;
break;
}
r = q;
}
}
free( p );
}
/* ========================================================================= */